home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.012.Menus / menus.inits.aii < prev    next >
Encoding:
Text File  |  1990-06-18  |  6.9 KB  |  343 lines  |  [TEXT/MPS ]

  1. *******************************************************************************
  2. *
  3. InitTools    PROC
  4. *
  5. * Description:    Load and initialize the tools needed. Errors are detected
  6. *    and FatalError is called if any occur. If there aren't any
  7. *    errors, the list of menu templates is read and the menu-
  8. *    bar is created.
  9. *
  10. *
  11. * Inputs:    NONE
  12. *
  13. * Outputs:    NONE
  14. *
  15. * External Refs:
  16.     import FatalError
  17. *
  18. * Entry Points:    NONE
  19. *
  20. *******************************************************************************
  21.     with Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage    equ $0000
  27. EMDPage    equ QDDPage+$0300
  28. CtlDPage    equ EMDPage+$0100
  29. MenuDPage    equ CtlDPage+$0100
  30. LEDPage    equ MenuDPage+$0100
  31. ToolDPSize    equ LEDPage+$0100
  32.  
  33.     phk    ; Save program bank register and
  34.     plb    ; load it as the data bank register
  35.  
  36.     tdc
  37.     sta MyDP    ; Save direct register
  38.  
  39.     _TLStartup    ; Start Tool Locator
  40.  
  41.     pha    ; Space for result
  42.     _MMStartup    ; Start memory manager
  43.     PullWord MyID    ; Save it for later use
  44.  
  45.     _MTStartup    ; Start up Misc Tools
  46.  
  47.     _IMStartup    ; Start integer math toolset
  48.  
  49.     PushLong #ToolTable    ; Pointer to Tool table
  50.     _LoadTools    ; Load all RAM based tools
  51.     bcc IT0005    ; Carry clear means no error
  52.     brl FatalError    ; Tools can't be loaded. Fatal error!
  53.  
  54. IT0005
  55.  
  56. ; Get memory for Tool Direct pages
  57.  
  58.     pha    ; Room for result
  59.     pha
  60.     PushLong #ToolDPSize; Number of bytes needed
  61.     PushWord MyID    ; ID of this application
  62.     PushWord #attrLocked+attrFixed+attrPage+attrBank
  63.     PushLong #0    ; Allocate them in bank 0
  64.     _NewHandle
  65.     bcc IT0010    ; Test carry for error
  66.     brl FatalError    ; If no memory we got a fatal error!
  67.  
  68. IT0010    PullLong DPHandle    ; Retrieve handle to our DPage area
  69.  
  70.     lda [DPHandle]    ; Dereference the handle to get a ptr
  71.     sta DPPointer    ; to our direct page area and save it.
  72.  
  73.     PushWord DPPointer    ; QuickDraw uses 3 pages of Dpage
  74.     PushWord #ScreenMode; Used to set all master SCB's
  75.     PushWord #0    ; Zero means use default buf size
  76.     PushWord MyID    ; Application ID for allocating data
  77.     _QDStartup    ; Start QuickDraw, turn on SHR Screen
  78.     bcc IT0015
  79.     brl FatalError    ; If it can't be started then bomb
  80.  
  81. IT0015
  82.     lda DPPointer    ; Create address for Event Mgr DPage by
  83.     clc    ; loading in the pointer to the start
  84.     adc #EMDPage    ; of DPage and adding Evt Mgr offset.
  85.     pha    ; Now push it on the stack.
  86.     PushWord #20    ; Size of event queue.
  87.     PushWord #0    ; MouseClamp values.
  88.     PushWord #ScreenWidth ; These will clamp mouse to screen
  89.     PushWord #0    ; area only.
  90.     PushWord #200
  91.     PushWord MyID
  92.     _EMStartup    ; Start the event manager
  93.     bcc IT0020
  94.     brl FatalError    ; Event manager is also a must
  95. IT0020
  96.     PushWord MyID
  97.     _WindStartup
  98.     bcc IT0025
  99.     brl FatalError
  100. IT0025
  101.     PushWord MyID
  102.     lda DPPointer
  103.     clc
  104.     adc #CtlDPage
  105.     pha
  106.     _CtlStartup
  107.     bcc IT0030
  108.     brl FatalError
  109. IT0030
  110.  
  111.     PushWord MyID
  112.     lda DPPointer
  113.     clc
  114.     adc #MenuDPage
  115.     pha
  116.     _MenuStartUp
  117.     bcc IT0035
  118.     brl FatalError
  119. IT0035
  120.     PushWord MyID
  121.     lda DPPointer
  122.     clc
  123.     adc #LEDPage
  124.     pha
  125.     _LEStartUp
  126.     bcc IT0040
  127.     brl FatalError
  128. IT0040
  129.     PushWord MyID
  130.     _DialogStartup
  131.     bcc IT0045
  132.     brl FatalError
  133. IT0045
  134.     _ListStartup
  135.  
  136.     _QDAuxStartup    ; no error possible for this call
  137.     
  138.     _ScrapStartup    ; No errors possible for this call
  139.  
  140.     _DeskStartup    ; No error possible for this call
  141.  
  142. ; insert application specific tools here
  143.  
  144.     PushLong #0
  145.     _RefreshDeskTop
  146.  
  147.     RTS
  148.  
  149. ToolTable    dc.W 8    ; Data Block for LoadTools call
  150.     dc.W 14,$0100    ; Window Manager
  151.     dc.W 15,$0100    ; Menu Manager
  152.     dc.W 16,$0100    ; Control Manager
  153.     dc.W 18,$0100    ; QDAux
  154.     dc.W 20,$0100    ; LineEdit tool set
  155.     dc.W 21,$0100    ; Dialog Manager
  156.     dc.W 22,$0100    ; Scrap manager
  157.     dc.W 28,$0100    ; List Manager
  158.  
  159.     ENDP
  160.  
  161.     EJECT
  162. *******************************************************************************
  163. *
  164. FatalError    PROC
  165. *
  166. * Description:    Routine that is called whenever a tool sends back an error
  167. *    that can not be recovered from. This routine prints the
  168. *    error on the screen, waits for a keypress then quits back
  169. *    to whoever started this application up!
  170. *
  171. *
  172. * Inputs:    A = Error number
  173. *
  174. * Outputs:    NONE (program exits)
  175. *
  176. * External Refs:
  177.     import CloseTools
  178. *
  179. * Entry Points:    NONE
  180. *
  181. *******************************************************************************
  182.     with Globals
  183.  
  184.     pha    ; Push the error code
  185.     PushLong #ErrNumStr    ; Address of storage area
  186.     PushWord #4    ; Length of string
  187.     _Int2Hex
  188.  
  189.     _GrafOff    ; If QD Started, shut off graphics
  190.  
  191.     PushLong #ErrStr    ; Write error message to the screen
  192.     _WriteCString
  193.  
  194.     pha    ; Space for result
  195.     PushWord #0    ; No echo
  196.     _ReadChar    ; Wait for a key to be pressed
  197.     pla    ; Discard the key
  198.  
  199.     jsr CloseTools    ; Shut down all the tools in case
  200. ;          any got started up
  201.  
  202.     _Quit QuitParms    ; Quit back to where we came from.
  203.  
  204.     brk $FF    ; If the quit fails then just break
  205.     
  206. ErrStr    dc.B 'A fatal error has occured $'
  207. ErrNumStr    dc.B 'xxxx   press any key to exit',0
  208.  
  209.     ENDP
  210.  
  211.     EJECT
  212. *******************************************************************************
  213. *
  214. CloseTools    PROC
  215. *
  216. * Description:    Shut down the tools I started.
  217. *
  218. *
  219. * Inputs:    NONE
  220. *
  221. * Outputs:    NONE
  222. *
  223. * External Refs:    NONE
  224. *
  225. * Entry Points:    NONE
  226. *
  227. *******************************************************************************
  228.     with Globals
  229.  
  230.     _ListShutdown
  231.     _QDAuxShutDown
  232.     _DeskShutDown
  233.     _ScrapShutDown
  234.     _DialogShutDown
  235.     _LEShutDown
  236.     _MenuShutDown
  237.     _CtlShutDown
  238.     _WindShutDown
  239.     _EMShutDown
  240.     _QDShutDown
  241.     _MTShutDown
  242.  
  243.     PushLong DPHandle    ; Dispose of all that DP memory
  244.     _DisposeHandle
  245.  
  246.     PushWord MyID
  247.     _MMShutDown
  248.     _TLShutDown
  249.  
  250.     rts
  251.     ENDP
  252.  
  253.     EJECT
  254. *******************************************************************************
  255. *
  256. DoAbout    PROC
  257. *
  258. * Description:    Bring up an Alert Dialog box with our name in it.
  259. *
  260. * Inputs:    NONE
  261. *
  262. * Outputs:    NONE
  263. *
  264. * External Refs:    NONE
  265. *
  266. * Entry Points:    NONE
  267. *
  268. *******************************************************************************
  269.     With Globals
  270.  
  271.     pha    ; space for result
  272.     PushLong #AboutBox    ; pointer to alert template
  273.     PushLong #0    ; pointer to a filter proc (0=none)
  274.     _NoteAlert
  275.     pla    ; get the item hit and dispose
  276.  
  277.     rts
  278.  
  279. ; About Box alert template
  280. ; About Box alert template
  281.  
  282. AboutBox
  283. atBoundsRect    dc.W 30,30,100,290    ; for 320 use
  284. atAlertID    dc.W 1    ; this is alert # 1
  285. atStage1    dc.B $80    ; draw for this stage
  286. atStage2    dc.B $81    ; draw for this stage
  287. atStage3    dc.B $82    ; draw for this stage
  288. atStage4    dc.B $83    ; draw for this stage
  289. atItem1    dc.L OKButton    ; ok button for the    alert
  290. atItem2    dc.L AboutTitle    ; title of the program
  291. atItem3    dc.L AboutAut    ; author
  292. atItem4    dc.L AboutCR    ; version number string
  293. atItem5    dc.L AboutVers    ; nill to end the list
  294. atEndList    dc.L 0
  295.  
  296. OKBTitle    dc.B 2,'OK'
  297. OKButton
  298.     dc.W 1
  299.     dc.W 50,200,65,250
  300.     dc.W $000A    ; standard button
  301.     dc.L OKBTitle
  302.     dc.W 0
  303.     dc.W 0    ; item flag
  304.     dc.L 0    ; no color table
  305.  
  306. AboutTitle
  307.     dc.W 2
  308.     dc.W 10,50,20,250
  309.     dc.W $800F    ; Stat Text
  310.     dc.L TitleString
  311.     dc.W 0
  312.     dc.W 0    ; item flag
  313.     dc.L 0    ; no color table
  314.  
  315. AboutAut
  316.     dc.W 3
  317.     dc.W 22,50,32,250
  318.     dc.W $800F    ; Stat Text
  319.     dc.L AutString
  320.     dc.W 0
  321.     dc.W 0    ; item flag
  322.     dc.L 0    ; no color table
  323.  
  324. AboutCR
  325.     dc.W 4
  326.     dc.W 34,50,46,250
  327.     dc.W $800F    ; Stat Text
  328.     dc.L CRString
  329.     dc.W 0
  330.     dc.W 0    ; item flag
  331.     dc.L 0    ; no color table
  332.  
  333. AboutVers
  334.     dc.W 5
  335.     dc.W 48,50,60,250
  336.     dc.W $800F    ; Stat Text
  337.     dc.L VersString
  338.     dc.W 0
  339.     dc.W 0    ; item flag
  340.     dc.L 0    ; no color table
  341.  
  342.     ENDP
  343.